#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 3e5 + 5;

int n, m, q, tot;
int x[N], y[N], z[N];
vector<int> out[N];
ll ans[N];
vector<ll> in[N];
int bit[N << 1];
int lowbit(int x) { return x & -x; }
void update(int x, int d) {
  for (int i = x; i <= tot; i += lowbit(i)) bit[i] += d;
}
int query(int x) {
  int sum = 0;
  for (int i = x; i > 0; i -= lowbit(i)) sum += bit[i];
  return sum;
}
int search(int x) {
  int l = x, h = tot;
  while (l <= h) {
    int mid = (l + h) >> 1;
    int cnt = query(mid);
    if (mid - query(mid) >= x)
      h = mid - 1;
    else
      l = mid + 1;
  }
  return l;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> q;
  tot = max(n, m) + q;
  rep(i, 1, q) cin >> x[i] >> y[i];
  // solve_out
  rep(i, 1, q) if (y[i] != m) out[x[i]].push_back(i);
  rep(i, 1, n) {
    for (int j : out[i]) {
      z[j] = search(y[j]);
      update(z[j], 1);
    }
    for (int j : out[i]) update(z[j], -1);  // restore
  }
  rep(i, 1, q) {
    int t = search(x[i]);
    update(t, 1);
    ll id1 = t <= n ? 1ll * t * m : in[0][t - n - 1];
    if (y[i] == m) {
      in[0].push_back(id1);
      ans[i] = id1;
    } else {
      ll id2 = z[i] <= m - 1 ? 1ll * (x[i] - 1) * m + z[i] : in[x[i]][z[i] - m];
      in[0].push_back(id2);
      in[x[i]].push_back(id1);
      ans[i] = id2;
    }
  }
  rep(i, 1, q) cout << ans[i] << endl;
  return 0;
}